﻿<Window x:Class="TeacherLoad.Windows.GroupList"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:TeacherLoad.Windows"
        mc:Ignorable="d"
        Title="Группы"
        Height="500" Width="900"
        MinHeight="500" MinWidth="900"
        WindowStartupLocation="CenterScreen"
        Background="#BFF7E9">
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="320"/>
            <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="*"/>
            <RowDefinition Height="25"/>
        </Grid.RowDefinitions>

        <GroupBox x:Name="HeaderGroupAdd"
            Header="Новая группа"
                  BorderBrush="#200772">
            <StackPanel>
                <Label Content="Специальность"/>
                <ComboBox x:Name="cbSpec"
                          ItemsSource="{Binding}"
                          SelectedValuePath="Id"
                          SelectionChanged="cbSpec_SelectionChanged">
                    <ComboBox.ItemTemplate>
                        <DataTemplate>
                            <StackPanel>
                                <Grid>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="1*"/>
                                        <ColumnDefinition Width="3*"/>
                                    </Grid.ColumnDefinitions>
                                    <TextBlock x:Name="txCodeSpec"
                                               Text="{Binding Path=Code}"
                                               Margin="0"/>
                                    <TextBlock x:Name="txNameSpec"
                                               Grid.Column="1"
                                               Text="{Binding Path=NameSpec}"
                                               Margin="2 0"
                                               TextWrapping="Wrap"/>
                                </Grid>
                                
                                <TextBlock x:Name="txQualif"
                                           Text="{Binding Path=Qualification}"
                                           TextWrapping="Wrap"/>
                            </StackPanel>
                        </DataTemplate>
                    </ComboBox.ItemTemplate>
                </ComboBox>
                <Label Content="Год утверждения учебного плана"/>
                <ComboBox x:Name="cbUchPlan"
                        ItemsSource="{Binding}"
                        SelectedValuePath="Id">
                    
                </ComboBox>
                <Label Content="Название группы"/>
                <TextBox x:Name="txNameGroup"/>
                
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="2*"/>
                        <ColumnDefinition Width="3*"/>
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="*"/>
                        <RowDefinition Height="*"/>
                    </Grid.RowDefinitions>
                    <Label Content="Курс"/>
                    <TextBox x:Name="txCourse"
                             Grid.Row="1"
                             Width="50"
                             HorizontalAlignment="Left"
                             PreviewTextInput="ValidationCours"/>
                    <Label Content="Год начала обучения"
                           Grid.Column="1"/>
                    <TextBox x:Name="txBeginYear"
                             Grid.Column="1"
                             Grid.Row="1" Width="50"
                             HorizontalAlignment="Left"
                             PreviewTextInput="ValidationYear"/>
                </Grid>
                
                
                <Button x:Name="btnAddGroup"
                        Content="Добавить группу"
                        Click="btnAddGroup_Click"/>
                <Button x:Name="btnCancelEdit"
                        Content="Отменить редактирование"
                        Visibility="Hidden"
                        Click="btnCancelEdit_Click"/>
            </StackPanel>
        </GroupBox>

        <GroupBox Grid.Column="1"
          Header="Список групп">
            <Grid x:Name="DataGroup">
                <ListBox x:Name="listGroup"
                 ItemsSource="{Binding}"
                 SelectionChanged="listGroup_SelectionChanged">
                    <ListBox.ItemTemplate>
                        <DataTemplate>
                            <StackPanel Orientation="Horizontal">
                                <TextBlock Text="{Binding Path=Name}"
                                           FontWeight="Bold"/>
                                <TextBlock Margin="15,0,0,0"
                                           Text="{Binding Path=BeginYearStr}"/>
                                <TextBlock Margin="15,0,0,0"
                                           Text="{Binding Path=SpecName}"/>
                            </StackPanel>
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                    <ListBox.ContextMenu>
                        <ContextMenu>
                            <MenuItem x:Name="ChangeRow"
                                Header="Изменить строку"
                                Click="ChangeRow_Click"/>
                        </ContextMenu>
                    </ListBox.ContextMenu>
                </ListBox>
            </Grid>
        </GroupBox>
        <StatusBar Grid.Row="1" Grid.ColumnSpan="2"
           Background="#BFF7E9">
            <StatusBarItem>
                <TextBlock Text="{Binding StringFormat=Количество строк: {0},
            ElementName=listGroup, Path=Items.Count}"
                   Margin="5 0"/>
            </StatusBarItem>
            
        </StatusBar>
    </Grid>
</Window>
